package krow.dev.gunpobus.view;

import krow.dev.gunpobus.R;
import android.content.Context;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

public class SearchViewWrapper {

	private View mRootView;

	private EditText mKeywordEditView;
	
	public SearchViewWrapper(Context context) {

		LayoutInflater layoutInflater = LayoutInflater.from(context);
		
		mRootView = layoutInflater.inflate(R.layout.header_search, null);
	
		mKeywordEditView = (EditText) mRootView.findViewById(R.id.edit_keyword);
		mKeywordEditView.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
	}
	
	public View getView(){
		
		return mRootView;
	}

	public void setHint(String hint){
		
		mKeywordEditView.setHint(hint);
	}
	
	public void setNumberOnly(){
		
		mKeywordEditView.setPrivateImeOptions("defaultInputmode=numeric");
		mKeywordEditView.setInputType(InputType.TYPE_CLASS_NUMBER);
	}
	
	public void addTextChangedListener(TextWatcher textWatcher){
		
		mKeywordEditView.addTextChangedListener(textWatcher);
	}
	
	public String getKeyword(){
		
		return mKeywordEditView.getText().toString();
	}
	
	public void clear(){
		
		mKeywordEditView.setText("");
	}
}
